package com.pureut.system.controller;

import java.util.Arrays;
import java.util.List;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.pureut.common.core.web.controller.BaseController;
import com.pureut.common.core.web.domain.AjaxResult;
import com.pureut.common.core.web.page.TableDataInfo;
import com.pureut.system.domain.ProductRepairRecord;
import com.pureut.system.domain.ReviewInformation;
import com.pureut.system.domain.vo.ReviewInformationVo;
import com.pureut.system.service.IReviewInformationService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


/**
 * @Author: pureut
 * @Date: 2025-04-08 16:06:15
 * @Desc: 评审信息表Controller
 */
@RestController
@RequestMapping("/system/reviewInformation")
public class ReviewInformationController extends BaseController {

    /**
     * 评审信息表Service
     */
    @Resource
    private IReviewInformationService reviewInformationService;

    /**
     * 查询评审信息表列表
     * @param: params 参数列表
     * @return: Json工具类对象
     */
    //    @SaCheckPermission("reviewInformation-list")
    @GetMapping("/list")
    public TableDataInfo list( ReviewInformationVo reviewInformationVo) {
        startPage();
        LambdaQueryWrapper<ReviewInformation> resultQuery = new LambdaQueryWrapper<ReviewInformation>();
        if(ObjectUtil.isNotNull(reviewInformationVo.getReviewCategory())){
            resultQuery.eq(ReviewInformation::getReviewCategory, reviewInformationVo.getReviewCategory());
        }
        if(ObjectUtil.isNotNull(reviewInformationVo.getReviewObject())){
            resultQuery.eq(ReviewInformation::getReviewObject, reviewInformationVo.getReviewObject());
        }
        if(ObjectUtil.isNotNull(reviewInformationVo.getStartTime())&&ObjectUtil.isNotNull(reviewInformationVo.getEndTime())){
            resultQuery.between(ReviewInformation::getCreateTime, reviewInformationVo.getStartTime(),reviewInformationVo.getEndTime());
        }
        if(ObjectUtil.isNotNull(reviewInformationVo.getImplementationDepartment())){
            resultQuery.eq(ReviewInformation::getImplementationDepartment, reviewInformationVo.getImplementationDepartment());
        }
        return getDataTable(reviewInformationService.list(resultQuery));
    }


    /**
     * 获取评审信息表详细信息
     * @param: id 评审信息表主键
     * @return: Json工具类对象
     */
    //    @SaCheckPermission("reviewInformation-query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(reviewInformationService.getById(id));
    }

    /**
     * 新增评审信息表
     * @param: reviewInformation 评审信息表对象
     * @return: Json工具类对象
     */
    //    @SaCheckPermission("reviewInformation-add")
    @PostMapping
    public AjaxResult add(@RequestBody ReviewInformationVo reviewInformationVo) {
        return toAjax(reviewInformationService.save(reviewInformationVo));
    }

    /**
     * 修改评审信息表
     * @param: reviewInformation 评审信息表对象
     * @return: Json工具类对象
     */
    //    @SaCheckPermission("reviewInformation-edit")
    @PutMapping
    public AjaxResult edit( @RequestBody ReviewInformationVo reviewInformationVo) {
        return toAjax(reviewInformationService.updateById(reviewInformationVo));
    }

    /**
     * 删除评审信息表
     * @param: id 评审信息表主键
     * @return: Json工具类对象
     */
    //    @SaCheckPermission("reviewInformation-remove")
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(reviewInformationService.removeByIds(Arrays.asList(ids)));
    }
}
